<template>
  <el-dialog :title="title" :visible.sync="dialogVisible" width="600px" append-to-body :close-on-click-modal="false">
    
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="用户选择" prop="sysUserId" :rules="{required:true,message:'用户不能为空',trigger:'change'}">
        <el-select v-model="form.sysUserId"></el-select>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="handleSubmit">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
    import {addChat, updateChat} from "@/api/system/chat.js";

    export default {
        props: {
            title: {
                type: String
            }
        },
        data() {
            return {
                dialogVisible: false,
                form: {
                    sysUserId: ''
                }
            }
        },
        methods: {

            handleSubmit() {
                this.$refs.form.validate(valid => {
                    if (valid) {
                        addChat(this.form).then(res => {
                          this.$message.success('添加成功！');
                        }).catch((err)=>{
                            this.$message.error(err);
                        })
                    }
                })
            },

            open() {
                this.dialogVisible = true;
            },
            close() {
                this.dialogVisible = false;
            }
        }
    }
</script>
